package com.myjava.list;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

public class listIteratorClass {
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        ListIterator it = list.listIterator();
        while(it.hasNext()){
            if(it.next().equals("2")){
                it.add("martin");
            }
        }
        System.out.println(list);
        while(it.hasPrevious()){
            System.out.println("preIndex="+it.previousIndex());
            System.out.println(it.previous());
        }
    }
}
